//
//  ILButton.m
//  miaopai
//
//  Created by Crow Zhang on 15/11/18.
//  Copyright © 2015年 Crow Zhang. All rights reserved.
//

#import "ILButton.h"

@implementation ILButton

- (void)dealloc
{
    [_image release];
    [_label release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}

- (void)creatView
{
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, self.frame.size.width - 30, self.frame.size.height - 30)];
    [self addSubview:self.image];
    self.image.layer.cornerRadius = (self.frame.size.width - 30) / 2;
    //self.image.layer.cornerRadius = 20;
    [_image release];
    
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, self.frame.size.height - 25, self.frame.size.width, 20)];
    self.label.textAlignment = NSTextAlignmentCenter;
    self.label.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.label];
    [_label release];
}

- (void)addMyTarget:(id)target action:(SEL)action
{
    self.target = target;
    self.action = action;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.target performSelector:self.action withObject:self];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
